package com.ysstech.system.enums;

import java.util.Arrays;
import java.util.Objects;

import com.ysstech.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum SystemEnum implements BaseEnum<String> {
    ERROR_TIMES("6","登录时密码允许错误次数"),
    USER_LOCKTIME("24","用户锁定时间（小时）"),
    RESET_PASSWORD("888888","新增或者重置用户的密码"),
    YSS_ORGANIZATION("YSS_ORGANIZATION", "机构的缓存key"),
    YSS_DICINFO("YSS_DICINFO", "字典数据缓存key"),
    SYS_ROLE_TYPE("SYS_ROLE_TYPE", "角色类型字典值"),
    SYS_STATUS("SYS_STATUS", "状态字典值"),
    SYS_ORGANIZATION_TYPE("SYS_ORGANIZATION_TYPE", "机构类型"),
    SYS_DIC_TYPE("SYS_DIC_TYPE", "字典类型"),
    SYS_MENU_TYPE("SYS_MENU_TYPE", "菜单类型");


    private final String code;
    private final String desc;

    public static SystemEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        SystemEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
